package com.techstar.mqttprocesser.service.mqtt.handler.device;

import com.techstar.mqttprocesser.service.mqtt.model.DeviceType;
import com.techstar.mqttprocesser.service.mqtt.model.JsonSingleModle;
import com.techstar.mqttprocesser.service.mqtt.utils.JsonDataParseUtil;
import com.techstar.mqttprocesser.service.mqtt.utils.TimeUtils;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author lilei
 * @create 2025-03-31-2025/3/31
 */
@Component
public class LuomiDeviceDataParse implements DeviceDataParse{

    @Override
    public DeviceType getDeviceType() {
        return DeviceType.luzhou;
    }

    @Override
    public LocalDateTime parseDataTime(String message) {
        //todo，这个获取jsonpath需要做成动态的
        JsonSingleModle time = JsonDataParseUtil.parseJsonData(message, "$.UploadTime", "time");
        //2025-04-03 17:13:53这种格式，转为LocalDateTime

        return TimeUtils.formatDateTime(time.getValue(), "yyyy-MM-dd HH:mm:ss");
    }

}
